<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<c:set var="ctx" scope="page" value="${request.contextPath}" />
<!DOCTYPE  >
<html >
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,viewport-fit=cover">
    <title>满意度评价</title>
    <link rel="stylesheet" type="text/css" href="${ctx}/static/weui/1.1.2/weui-for-work.min.css"/>
    <link rel="stylesheet" type="text/css" href="${ctx}/static/weixin/style/customer.css"/>
    <script type="text/javascript" src="${ctx}/static/jquery/jquery-1.8.3.min.js"></script>
    <%--<script type="text/javascript" src="https://res.wx.qq.com/open/libs/weuijs/1.1.2/weui.min.js"></script>--%>
    <!-- 企业微信的JS-SDK -->
    <%--<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>--%>

</head>

<body>
<!--头部  star-->
<header>
    <a href="javascript:history.go(-1);">
        <div class="_left"><img src="${ctx}/static/weixin/images/left.png"></div>
        评价
    </a>
</header>
<!--头部 end-->
<!--内容 star-->
<div class="contaniner fixed-cont">
    <!--1-->
    <!--2-->
    <center style="margin:10px 0px;">请对本次服务进行评价</center>
    <section class="main">
        <div class="main-wrap">
            <center class="revtit">服务质量</center>
            <div id="mydiv1" currentIndex="0" class="mydiv">
                <ul class="star_ul">
                    <li num="1"><img src="${ctx}/static/weixin/images/star_empty.png" class="xing_hui"/></li>
                    <li num="2"><img src="${ctx}/static/weixin/images/star_empty.png"  class="xing_hui"/></li>
                    <li num="3"><img src="${ctx}/static/weixin/images/star_empty.png"  class="xing_hui"/></li>
                    <li num="4"><img src="${ctx}/static/weixin/images/star_empty.png"  class="xing_hui"/></li>
                    <li num="5"><img src="${ctx}/static/weixin/images/star_empty.png"  class="xing_hui"/></li>
                </ul>
                <input name="qualityOfService" value="" hidden>
            </div>
        </div>
    </section>
    <section class="main">
        <div class="main-wrap">
            <center class="revtit">服务态度</center>
            <div id="mydiv2" currentIndex="0" class="mydiv">
                <ul class="star_ul">
                    <li num="1"><img src="${ctx}/static/weixin/images/star_empty.png" class="xing_hui"/></li>
                    <li num="2"><img src="${ctx}/static/weixin/images/star_empty.png"  class="xing_hui"/></li>
                    <li num="3"><img src="${ctx}/static/weixin/images/star_empty.png"  class="xing_hui"/></li>
                    <li num="4"><img src="${ctx}/static/weixin/images/star_empty.png"  class="xing_hui"/></li>
                    <li num="5"><img src="${ctx}/static/weixin/images/star_empty.png"  class="xing_hui"/></li>
                    <input name="serviceAttitude" value="" hidden>
                </ul>
            </div>
        </div>
    </section>
    <section class="assess">
        <p>
            <textarea rows="7" name="description" placeholder="请反馈您的宝贵意见帮助我们持续提升服务水平"></textarea>
        </p>
        <!-- <ul>
            <li>评价</li>
            <li class="assess-right">
                <div><input type="radio" name="radio" value="radio1"/><img src="${ctx}/static/weixin/images/hua.png"/></div>
                <div><input type="radio" name="radio" value="radio2"/><img src="${ctx}/static/weixin/images/huah.png"/></div>
                <div><input type="radio" name="radio" value="radio3"/><img src="${ctx}/static/weixin/images/huae.png"</div>
            </li>
        </ul> -->
    </section>
    <!--BEGIN toast-->
    <div id="toast" style="display: none;">
        <div class="weui-mask_transparent"></div>
        <div class="weui-toast">
            <i class="weui-icon-success-no-circle weui-icon_toast"></i>
            <p class="weui-toast__content" id="alertMsg">已评价完成</p>
        </div>
    </div>
    <!--end toast-->
</div>
<!--内容 end-->

<!--底部 star-->
<%--<footer class="assess-footer fixed-footer ">
    <ul>
        <input type="button" value="提交" onclick="addCustomerSatisfaction()"/>
    </ul>
</footer>--%>
<div class="weui-btn-area">
    <a class="weui-btn weui-btn_primary"  href="#" onclick="javascript:addCustomerSatisfaction()" id="showTooltips">提交</a>
</div>
<!--底部  end-->
<script type="text/javascript">
    $(".assess-footer ul li label").on('touchstart',function(){
        if($(this).hasClass('assd')){
            $(".assess-footer ul li label").removeClass("assd")
        }else{
            $(".assess-footer ul li label").addClass("assd")
        };
    });

    function change(mydivid,num) {
        var tds = $("#"+mydivid+" ul li");
        for (var i = 0; i < num; i++) {
            var td = tds[i];
            $(td).find("img").attr("src","${ctx}\/static\/weixin\/images\/star_full.png");
        }
        var tindex = $("#"+mydivid).attr("currentIndex");
        tindex = tindex==0?0:tindex+1;
        for (var j = num; j < tindex; j++) {
            var td = tds[j];
            $(td).find("img").attr("src","${ctx}\/static\/weixin\/images\/star_empty.png");
        }
        $("#"+mydivid).find("input").val(num);
        $("#"+mydivid).attr("currentIndex",num);
    }
    $(function(){
        initEvent('mydiv1');
        initEvent('mydiv2');
    });
    function initEvent(mydivid) {
        var tds = $("#"+mydivid+" ul li");
        for (var i = 0; i < tds.length; i++) {
            var td = tds[i];
            $(td).live('mouseover',function(){var num = $(this).attr("num");change(mydivid,num);});
        }
    }

</script>
</body>

<script>
    var checkSubmitFlg = true;
    $(function () {
        //然后被跳转的页：
        sessionStorage.setItem("need-refresh", true);
    });
    function addCustomerSatisfaction(workOrderId){
        var qualityOfService=$("[name=qualityOfService]").val();
        var serviceAttitude=$("[name=serviceAttitude]").val();
        if(qualityOfService=="undefined"||qualityOfService==""){
            setMessager("请对服务质量进行评价");
            return;
        }
        if(serviceAttitude=="undefined"||serviceAttitude==""){
            setMessager("请对服务态度进行评价");
            return;
        }
        if (checkSubmitFlg == true) {
        $.post( '${ctx}/weixin/customerSatisfaction/add',{
            workOrderId:"${repaireCustomerVO.workOrderId}",
            satisfied:$('input[name=satisfied]:checked').val(),
            description:$("textarea[name=description]").val(),
            qualityOfService:$("[name=qualityOfService]").val(),
            serviceAttitude:$("[name=serviceAttitude]").val()
        },function (result) {
            var json = JSON.parse(result);
            if(json.code=='0'){
                setMessager("已评价完成");
//                location.href = '/weixin/success.jsp'
                location.href = '${ctx}/weixin/repaire/list'
//                WeixinJSBridge.call('closeWindow');
            }else {
                alert('提交失败'+json.msg);
            }
        });
            checkSubmitFlg = false;
        }
    }
    function setMessager(msg){
        var $toast = $('#toast');
        $("#alertMsg").html(msg);
        if ($toast.css('display') != 'none') return;

        $toast.fadeIn(100);
        setTimeout(function () {
            $toast.fadeOut(100);
        }, 2000);
    }


</script>
</html>
